home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / a_utils / _archvrs / unix / unzip51 / nt / nt.c < prev   
Encoding:
C/C++ Source or Header  |  1992-10-12  |  2.2 KB  |  77 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.   nt.c
  4.  
  5.   WinNT-specific routines for use with Info-ZIP's UnZip 5.1 and later.
  6.  
  7.   ---------------------------------------------------------------------------*/
  8.  
  9.  
  10. #include "unzip.h"
  11.  
  12.  
  13. /**********************/
  14. /* Function mapattr() */
  15. /**********************/
  16.  
  17. int mapattr()   /* identical to MS-DOS, OS/2 versions */
  18. {
  19.     /* set archive bit (file is not backed up): */
  20.     pInfo->file_attr = (unsigned)crec.external_file_attributes | 32;
  21.     return 0;
  22.  
  23. } /* end function mapattr() */
  24.  
  25.  
  26.  
  27.  
  28.  
  29. /**************************************/
  30. /* Function set_file_time_and_close() */
  31. /**************************************/
  32.  
  33. void set_file_time_and_close()
  34. {
  35.     FILETIME ft;     /* 64-bit value made up of two 32 bit [low & high] */
  36.     WORD wDOSDate;   /* for vconvertin from DOS date to Windows NT */
  37.     WORD wDOSTime;
  38.     HANDLE hFile;    /* file handle (defined in Windows NT) */
  39.  
  40.  
  41.     /* don't set the time stamp on standard output */
  42.     if (cflag) {
  43.         close(outfd);
  44.         return;
  45.     }
  46.  
  47.     /* Copy and/or convert time and date variables, if necessary; then set the
  48.      * file time/date. */
  49.     wDOSTime = (WORD)lrec.last_mod_file_time;
  50.     wDOSDate = (WORD)lrec.last_mod_file_date;
  51.  
  52.     /* The DosDateTimeToFileTime() function converts a DOS date/time
  53.      * into a 64 bit Windows NT file time */
  54.     DosDateTimeToFileTime(wDOSDate, wDOSTime, &ft);
  55.  
  56.     /* Close the file and then re-open it using the Win32
  57.      * CreateFile call, so that the file can be created
  58.      * with GENERIC_WRITE access, otherwise the SetFileTime
  59.      * call will fail. */
  60.     close(outfd);
  61.  
  62. #if 0  /* this was at the very end of the routine (never reached):  here? */
  63.     if (!SetFileAttributes(filename, pInfo->file_attr & 0x7F))
  64.         fprintf(stderr, "\nwarning (%d): could not set file attributes\n",
  65.           GetLastError());
  66. #endif
  67.  
  68.     hFile = CreateFile(filename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
  69.          FILE_ATTRIBUTE_NORMAL, NULL);
  70.  
  71.     if (!SetFileTime(hFile, NULL, NULL, &ft))
  72.         printf("\nSetFileTime failed: %d\n", GetLastError());
  73.     CloseHandle(hFile);
  74.     return;
  75.  
  76. } /* end function set_file_time_and_close() */
  77.